const path = require('path');

module.exports = {
  entry: './src/libs/client/client-entry.js',
  output: {
    filename: 'client.js',
    path: path.resolve(__dirname, 'dist'),
    clean: false,
    library: {
      name: 'McpClient',
      type: 'umd'
    }
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
        },
      },
    ],
  },
  resolve: {
    extensions: ['.js'],
    fallback: {
      stream: false,
      crypto: false,
      buffer: false,
      fs: false,
      path: false,
      os: false,
    },
  },
  // 移除了externals设置，因为在浏览器环境中没有commonjs模块系统
  // 这些依赖项现在将被直接打包到client.js中
  externals: {},
  // 为了更好的浏览器兼容性，添加这些配置
  target: 'web',
  node: {
    global: true,
    __filename: false,
    __dirname: false
  },
  mode: 'production',
  optimization: {
    minimize: true
  }
};